package SellTask;
public class SellTicket implements Runnable {
    int maxCount = 300;

    @Override
    public void run() {
        while (true) {
            sellTicket();
            if(maxCount<=0){
                return;
            }
        }
    }
    private synchronized void sellTicket() {
        if(maxCount>0){
            System.out.println(Thread.currentThread().getName()+"卖了【想见你】票号为"+maxCount);
            maxCount--;
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

        }
    }
}

